package com.example.liwushuo.fragment;

import com.example.liwushuo.BaseApp;
import com.example.liwushuo.R;
import com.example.liwushuo.urls.urls;
import com.lidroid.xutils.exception.HttpException;
import com.lidroid.xutils.http.ResponseInfo;
import com.lidroid.xutils.http.callback.RequestCallBack;
import com.lidroid.xutils.http.client.HttpRequest.HttpMethod;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.webkit.WebView;

public class OneGoodsImageInfo extends Fragment {

	private WebView web;
	private String url;

	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);

		url = urls.getOneImageUrl + getArguments().getLong("id");
		Log.i("url", "---------url" + url);

	}

	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container,
			Bundle savedInstanceState) {

		View view = inflater.inflate(R.layout.one_goods_imginfo, null);

		web = (WebView) view.findViewById(R.id.one_goods_img_id);
		loadData();
		return view;
	}

	private void loadData() {
		if (url != null) {
			BaseApp.getHttpUtils().send(HttpMethod.GET, url,
					new RequestCallBack<String>() {

						@Override
						public void onFailure(HttpException arg0, String arg1) {

							BaseApp.getToast("网络连接错误，请检查网络连接");

						}

						@Override
						public void onSuccess(ResponseInfo<String> response) {
							Log.i("web", "-----------这里执行了");

							web.loadData(response.result,
									"text/html;charset=utf-8", "utf-8");
						}
					});
		}
	}

}
